<?php
namespace frontend\controllers;

use Yii;
use common\models\CourseClass;
use yii\data\ActiveDataProvider;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;

/**
 * CourseClassController implements the CRUD actions for CourseClass model.
 */
class CourseClassController extends Controller
{

    /**
     * @inheritdoc
     */
    public function behaviors()
    {
        return [
            'verbs' => [
                'class' => VerbFilter::className(),
                'actions' => [
                    'delete' => [
                        'POST'
                    ]
                ]
            ]
        ];
    }

    /**
     * Lists all CourseClass models.
     * 
     * @return mixed
     */
    public function actionIndex()
    {
        $model = CourseClass::find()->orderBy('hot desc')->all();
        return $this->render('index', [
            'model' => $model
        ]);
    }

    /**
     * Finds the CourseClass model based on its primary key value.
     * If the model is not found, a 404 HTTP exception will be thrown.
     * 
     * @param string $id            
     * @return CourseClass the loaded model
     * @throws NotFoundHttpException if the model cannot be found
     */
    protected function findModel($id)
    {
        if (($model = CourseClass::findOne($id)) !== null) {
            return $model;
        } else {
            throw new NotFoundHttpException('The requested page does not exist.');
        }
    }
}
